/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.server.modules.sys.service.juhe.usedcar;

import com.server.common.persistence.Page;
import com.server.common.service.CrudService;
import com.server.common.utils.StringUtils;
import com.server.modules.sys.dao.juhe.usedcar.JuheUsedcarProvinceDao;
import com.server.modules.sys.entity.juhe.usedcar.JuheUsedcarProvince;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 聚合二手车接口地区省份数据Service
 * @author 丁光彪
 * @version 2017-01-06
 */
@Service
@Transactional(readOnly = true)
public class JuheUsedcarProvinceService extends CrudService<JuheUsedcarProvinceDao, JuheUsedcarProvince> {

	public JuheUsedcarProvince get(String id) {
		return super.get(id);
	}
	@Transactional(readOnly = false)
	public boolean saveAllProvince(List<JuheUsedcarProvince> list){
		//删除旧的省份
        dao.deleteAll();
        if(!CollectionUtils.isEmpty(list)){
			for (JuheUsedcarProvince juheUsedcarProvince : list) {
                String id = juheUsedcarProvince.getId();
                if(StringUtils.isNotBlank(id)){
                    juheUsedcarProvince.preInsert();
                    juheUsedcarProvince.setId(id);
					dao.insert(juheUsedcarProvince);
				}
			}
			return true;
		}
		return false;
	}

	public List<JuheUsedcarProvince> findList(JuheUsedcarProvince juheUsedcarProvince) {
		return super.findList(juheUsedcarProvince);
	}
	
	public Page<JuheUsedcarProvince> findPage(Page<JuheUsedcarProvince> page, JuheUsedcarProvince juheUsedcarProvince) {
		return super.findPage(page, juheUsedcarProvince);
	}
	
	@Transactional(readOnly = false)
	public void save(JuheUsedcarProvince juheUsedcarProvince) {
		super.save(juheUsedcarProvince);
	}
	
	@Transactional(readOnly = false)
	public void delete(JuheUsedcarProvince juheUsedcarProvince) {
		super.delete(juheUsedcarProvince);
	}
	
}